<?php

namespace app\api\model;

class RecyclePriceModel extends BaseModel
{
    protected $pk = 'id';
    protected $table = 'hs_recycle_price';
    protected static $tableName = 'recycle_price';

    //状态常量
    const STATUS_CLOSE = 0;//禁用
    const STATUS_OPEN = 1;//启用

    public static function lst()
    {
        $categorys = CategoryModel::typeArr(CategoryModel::TYPE_RECYCLE);
        $list = self::where('status', self::STATUS_OPEN)->order('weigh')->field('id,category_id,name,price')->select();
        foreach ($list as $k => $value) {
            $list[$k]['category_name'] = isset($categorys[$value['category_id']]) ? $categorys[$value['category_id']] : '';
        }
        return $list;
    }

    public static function priceArr()
    {
        return self::where('status', self::STATUS_OPEN)->column('price', 'category_id');
    }
}